package Demo02;

class Food {
}
class Fruit extends Food {
}
class Apple extends Fruit {
}
class Banana extends Fruit {
}
class Message<T> { // 设置泛型
    private T message ;
    public T getMessage() {
        return message;
    }
    public void setMessage(T message) {
        this.message = message;
    }
}


public class Test {
    public static void main(String[] args) {
        Message<Fruit> message = new Message<>();
        Message<Food> message1 = new Message<>();
        fun2(message);
        fun2(message1);
    }

    public static void fun2(Message<? super Fruit> temp){
        System.out.println(temp.getMessage());
    }
    public static void main01(String[] args) {
        Message<Apple> message = new Message<>();
        Message<Banana> message1 = new Message<>();
        fun(message);
        fun(message1);

    }

    public static void fun(Message<? extends Fruit> temp){
        System.out.println(temp.getMessage());
    }
}
